#region Copyright (c) 2000-2011 Developer Express Inc.
/*
{*******************************************************************}
{                                                                   }
{       Developer Express .NET Component Library                    }
{                                                                   }
{                                                                   }
{       Copyright (c) 2000-2011 Developer Express Inc.              }
{       ALL RIGHTS RESERVED                                         }
{                                                                   }
{   The entire contents of this file is protected by U.S. and       }
{   International Copyright Laws. Unauthorized reproduction,        }
{   reverse-engineering, and distribution of all or any portion of  }
{   the code contained in this file is strictly prohibited and may  }
{   result in severe civil and criminal penalties and will be       }
{   prosecuted to the maximum extent possible under the law.        }
{                                                                   }
{   RESTRICTIONS                                                    }
{                                                                   }
{   THIS SOURCE CODE AND ALL RESULTING INTERMEDIATE FILES           }
{   ARE CONFIDENTIAL AND PROPRIETARY TRADE                          }
{   SECRETS OF DEVELOPER EXPRESS INC. THE REGISTERED DEVELOPER IS   }
{   LICENSED TO DISTRIBUTE THE PRODUCT AND ALL ACCOMPANYING .NET    }
{   CONTROLS AS PART OF AN EXECUTABLE PROGRAM ONLY.                 }
{                                                                   }
{   THE SOURCE CODE CONTAINED WITHIN THIS FILE AND ALL RELATED      }
{   FILES OR ANY PORTION OF ITS CONTENTS SHALL AT NO TIME BE        }
{   COPIED, TRANSFERRED, SOLD, DISTRIBUTED, OR OTHERWISE MADE       }
{   AVAILABLE TO OTHER INDIVIDUALS WITHOUT EXPRESS WRITTEN CONSENT  }
{   AND PERMISSION FROM DEVELOPER EXPRESS INC.                      }
{                                                                   }
{   CONSULT THE END USER LICENSE AGREEMENT FOR INFORMATION ON       }
{   ADDITIONAL RESTRICTIONS.                                        }
{                                                                   }
{*******************************************************************}
*/
#endregion Copyright (c) 2000-2010 Developer Express Inc.

namespace DevExpress.OAuth.Web.Authentication {
    using System;
    using System.Security.Principal;

    [Serializable]
    public class MixedAuthenticationIdentity : MarshalByRefObject, IIdentity {
        public MixedAuthenticationIdentity(
                string identity, 
                string email, 
                Nullable<Guid> principal, 
                string type, 
                string fullName,
                string pictureUrl) {
                    
            if (String.IsNullOrEmpty(identity)) {
                throw new ArgumentNullException("identity");
            }
            if (String.IsNullOrEmpty(type)) {
                throw new ArgumentNullException("type");
            }
            _identity = identity;
            _authenticationType = type;
            _principal = principal;
            _email = email;
            _fullName = fullName;
            _pictureUrl = pictureUrl;
        }

        public MixedAuthenticationIdentity(
                string identity,
                string email,
                Nullable<Guid> principal,
                string type,
                string fullName) 
            : this(identity, email, principal, type, fullName, String.Empty) {
        }

        public MixedAuthenticationTicket CreateTicket() {
            return new MixedAuthenticationTicket(
                                AuthenticationType,
                                Name,
                                Email,
                                Principal,
                                FullName,
                                PictureUrl);  
        }

        string _fullName;
        public string FullName {
            get {
                return _fullName;
            }
        }

        string _email;
        public string Email {
            get {
                return _email;
            }
        }

        string _pictureUrl;
        public string PictureUrl {
            get {
                return _pictureUrl;
            }
        }

        string _authenticationType;
        public string AuthenticationType {
            get { 
                return _authenticationType; 
            }
        }

        public bool IsAuthenticated {
            get {
                return !string.IsNullOrEmpty(_authenticationType) &&
                        !string.IsNullOrEmpty(_identity);  
            }
        }
        
        readonly Nullable<Guid> _principal;
        public Nullable<Guid> Principal {
            get {
                return _principal;
            }
        }

        string _identity;
        public string Name {
            get { 
                return _identity; 
            }
        }
    }
}